
<!DOCTYPE HTML>
<html lang="Chinese" >
    <head>
        <title>低功耗支持 · freeRTOS中文文档</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.0">
        <meta name="author" content="tangguocheng">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prismx/prism.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="运行时间统计.html" />
    
    
    <link rel="prev" href="跟踪特性.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.xn--4gqa63c686ta68iba.ren/" target="_blank" class="custom-link">博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    关于
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../简介/freeRTOS介绍.html">
            
                <a href="../../简介/freeRTOS介绍.html">
            
                    
                    简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../简介/编码规则和风格.html">
            
                <a href="../../简介/编码规则和风格.html">
            
                    
                    编码规则和风格
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../简介/许可.html">
            
                <a href="../../简介/许可.html">
            
                    
                    许可
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../简介/快速开始指南.html">
            
                <a href="../../简介/快速开始指南.html">
            
                    
                    快速开始指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../入门/readme.html">
            
                <a href="../../入门/readme.html">
            
                    
                    入门
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../入门/任务和协程/readme.html">
            
                <a href="../../入门/任务和协程/readme.html">
            
                    
                    任务和协程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="../../入门/任务和协程/任务.html">
            
                <a href="../../入门/任务和协程/任务.html">
            
                    
                    任务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="../../入门/任务和协程/协程.html">
            
                <a href="../../入门/任务和协程/协程.html">
            
                    
                    协程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../入门/通信机制/readme.html">
            
                <a href="../../入门/通信机制/readme.html">
            
                    
                    通信机制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.2.1" data-path="../../入门/通信机制/队列.html">
            
                <a href="../../入门/通信机制/队列.html">
            
                    
                    队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.2" data-path="../../入门/通信机制/二值信号量.html">
            
                <a href="../../入门/通信机制/二值信号量.html">
            
                    
                    二值信号量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.3" data-path="../../入门/通信机制/计数信号量.html">
            
                <a href="../../入门/通信机制/计数信号量.html">
            
                    
                    计数信号量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.4" data-path="../../入门/通信机制/互斥量.html">
            
                <a href="../../入门/通信机制/互斥量.html">
            
                    
                    互斥量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.5" data-path="../../入门/通信机制/递归互斥量.html">
            
                <a href="../../入门/通信机制/递归互斥量.html">
            
                    
                    递归互斥量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.6" data-path="../../入门/通信机制/任务通知.html">
            
                <a href="../../入门/通信机制/任务通知.html">
            
                    
                    任务通知
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../入门/事件组/事件组.html">
            
                <a href="../../入门/事件组/事件组.html">
            
                    
                    事件组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../../入门/软件定时器/软件定时器.html">
            
                <a href="../../入门/软件定时器/软件定时器.html">
            
                    
                    软件定时器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../readme.md">
            
                <span>
            
                    
                    进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../源代码组织结构/源代码组织结构.html">
            
                <a href="../源代码组织结构/源代码组织结构.html">
            
                    
                    源代码组织结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="配置文件.html">
            
                <a href="配置文件.html">
            
                    
                    配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="跟踪特性.html">
            
                <a href="跟踪特性.html">
            
                    
                    跟踪特性
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.4" data-path="低功耗支持.html">
            
                <a href="低功耗支持.html">
            
                    
                    低功耗支持
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="运行时间统计.html">
            
                <a href="运行时间统计.html">
            
                    
                    运行时间统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="队列集合.html">
            
                <a href="队列集合.html">
            
                    
                    队列集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="中断延迟.html">
            
                <a href="中断延迟.html">
            
                    
                    中断延迟
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="静态分配与动态分配.html">
            
                <a href="静态分配与动态分配.html">
            
                    
                    静态和动态内存分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="内存管理.html">
            
                <a href="内存管理.html">
            
                    
                    内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="栈溢出检测.html">
            
                <a href="栈溢出检测.html">
            
                    
                    栈溢出检测
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="钩子函数.html">
            
                <a href="钩子函数.html">
            
                    
                    钩子函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="线程本地存储.html">
            
                <a href="线程本地存储.html">
            
                    
                    线程本地存储
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.13" data-path="移植指南.html">
            
                <a href="移植指南.html">
            
                    
                    移植指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.14" data-path=".">
            
                <span>
            
                    
                    在windows上模拟
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >低功耗支持</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x529F;&#x8017;&#x8282;&#x7701;&#x7B80;&#x4ECB;">&#x529F;&#x8017;&#x8282;&#x7701;&#x7B80;&#x4ECB;</h2><p>&#x5728;&#x7A7A;&#x95F2;&#x4EFB;&#x52A1;&#x4E2D;&#x653E;&#x7F6E;&#x5904;&#x7406;&#x5668;&#x7684;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#x4EE3;&#x7801;&#x662F;&#x5E38;&#x7528;&#x7684;&#x8282;&#x7701;&#x529F;&#x8017;&#x7684;&#x4E00;&#x79CD;&#x65B9;&#x5F0F;&#x3002;&#x529F;&#x8017;&#x8282;&#x7701;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8FD9;&#x79CD;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x5F0F;&#x5B9E;&#x73B0;&#xFF0C;&#x4F46;&#x662F;&#x53D7;&#x9650;&#x4E8E;&#x9700;&#x8981;&#x5468;&#x671F;&#x6027;&#x7684;&#x9000;&#x51FA;&#x5E76;&#x4E14;&#x91CD;&#x65B0;&#x8FDB;&#x5165;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#x53BB;&#x5904;&#x7406;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x3002;&#x4F46;&#x662F;&#x5982;&#x679C;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x7684;&#x9891;&#x7387;&#x5F88;&#x9AD8;&#xFF0C;&#x4E0D;&#x65AD;&#x7684;&#x9000;&#x51FA;&#x548C;&#x91CD;&#x65B0;&#x8FDB;&#x5165;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#x53EF;&#x80FD;&#x4F1A;&#x6F5C;&#x5728;&#x7684;&#x5BFC;&#x81F4;&#x529F;&#x8017;&#x8282;&#x7701;&#x8FBE;&#x4E0D;&#x5230;&#x9884;&#x671F;&#x6548;&#x679C;&#x3002;</p><p>freeRTOS&#x7684;&#x4F4E;&#x8282;&#x62CD;&#x7A7A;&#x95F2;&#x6A21;&#x5F0F;&#x53EF;&#x4EE5;&#x505C;&#x6B62;&#x5468;&#x671F;&#x6027;&#x7684;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#xFF0C;&#x5728;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x91CD;&#x65B0;&#x5F00;&#x59CB;&#x65F6;&#x4FEE;&#x6B63;RTOS&#x7684;&#x8282;&#x62CD;&#x8BA1;&#x6570;&#x503C;&#x3002;</p><p>&#x505C;&#x6B62;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x5141;&#x8BB8;&#x5904;&#x7406;&#x5668;&#x8FDB;&#x5165;&#x4E00;&#x4E2A;&#x66F4;&#x6DF1;&#x5C42;&#x6B21;&#x7684;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#xFF0C;&#x76F4;&#x5230;&#x5176;&#x4ED6;&#x4E2D;&#x65AD;&#x53D1;&#x751F;&#x6216;&#x8005;RTOS&#x5185;&#x6838;&#x5C06;&#x4E00;&#x4E2A;&#x4EFB;&#x52A1;&#x8F6C;&#x6362;&#x4E3A;&#x5C31;&#x7EEA;&#x6001;&#x3002;</p><h2 id="portsuppressticksandsleep-&#x5B8F;">portSUPPRESS_TICKS_AND_SLEEP() &#x5B8F;</h2><p><code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span> xExpectedIdleTime <span class="token punctuation">)</span></code></p><p>&#x5C06;<code>configUSE_TICKLESS_IDLE</code>&#x8BBE;&#x7F6E;&#x4E3A;1&#xFF0C;&#x5C06;&#x4F7F;&#x7528;&#x5185;&#x5EFA;&#x7684;&#x4F4E;&#x8282;&#x62CD;&#x7A7A;&#x95F2;&#x51FD;&#x6570;&#xFF0C;&#x8BBE;&#x7F6E;&#x4E3A;2&#xFF0C;&#x4F7F;&#x7528;&#x7528;&#x6237;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x51FD;&#x6570;&#x3002;</p><p>&#x5F53;&#x4F4E;&#x8282;&#x62CD;&#x7A7A;&#x95F2;&#x51FD;&#x6570;&#x53EF;&#x7528;&#x65F6;&#xFF0C;&#x5185;&#x6838;&#x4F1A;&#x5728;&#x6EE1;&#x8DB3;&#x5982;&#x4E0B;&#x6761;&#x4EF6;&#x65F6;&#x8C03;&#x7528; portSUPPRESS_TICKS_AND_SLEEP() &#x5B8F;&#xFF1A;</p><ol><li>&#x7A7A;&#x95F2;&#x4EFB;&#x52A1;&#x662F;&#x5F53;&#x524D;&#x552F;&#x4E00;&#x53EF;&#x6267;&#x884C;&#x4EFB;&#x52A1;&#xFF0C;&#x5176;&#x4ED6;&#x4EFB;&#x52A1;&#x5747;&#x5904;&#x5728;&#x963B;&#x585E;&#x6001;&#x3002;
</li>
<li>&#x81F3;&#x5C11;&#x9700;&#x8981;&#x8FC7;<code>n</code>&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x8282;&#x62CD;&#x5468;&#x671F;&#xFF0C;&#x5728;&#x6B64;&#x671F;&#x95F4;&#x6CA1;&#x6709;&#x4EFB;&#x52A1;&#x8FDB;&#x5165;&#x5C31;&#x7EEA;&#x6001;&#x3002;<code>n</code>&#x7684;&#x503C;&#x901A;&#x8FC7;<code>configEXPECTED_IDLE_TIME_BEFORE_SLEEP</code>&#x5B9A;&#x4E49;
</li></ol>
<p><code>portSUPPRESS_TICKS_AND_SLEEP</code>&#x5B8F;&#x7684;&#x53C2;&#x6570;&#x503C;&#x7B49;&#x4E8E;&#x4EFB;&#x52A1;&#x8FDB;&#x5165;&#x5C31;&#x7EEA;&#x6001;&#x4E4B;&#x524D;&#x7684;&#x603B;&#x7684;&#x8282;&#x62CD;&#x5468;&#x671F;&#x6570;&#x3002;&#x5728;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x503C;&#x7684;&#x65F6;&#x95F4;&#x5185;&#xFF0C;&#x5904;&#x7406;&#x5668;&#x5C06;&#x5B89;&#x5168;&#x7684;&#x5904;&#x5728;&#x6DF1;&#x7761;&#x7720;&#x72B6;&#x6001;&#xFF08;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x5173;&#x95ED;&#xFF09;&#x3002;</p><p>&#x6CE8;&#x610F;: &#x5982;&#x679C;&#x5728;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x4E2D;&#x8C03;&#x7528;<code>eTaskConfirmSleepModeStatus<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#xFF0C;&#x5E76;&#x4E14;&#x5176;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;<code>eNoTasksWaitingTimeout</code>&#x5219;&#xFF0C;&#x5904;&#x7406;&#x5668;&#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x671F;&#x7684;&#x5904;&#x5728;&#x6DF1;&#x7761;&#x7720;&#x72B6;&#x6001;&#xFF0C;&#x56E0;&#x4E3A;&#x6B64;&#x65F6;&#x6CA1;&#x6709;&#x4EFB;&#x52A1;&#x5728;&#x7B49;&#x5F85;&#x6267;&#x884C;&#x3002;&#x53EA;&#x6709;&#x5728;&#x5982;&#x4E0B;&#x6761;&#x4EF6;&#x4E3A;&#x771F;&#x662F;&#xFF0C;<code>eTaskConfirmSleepModeStatus<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x624D;&#x4F1A;&#x662F;<code>eNoTasksWaitingTimeout</code>:</p><ol><li>&#x8F6F;&#x4EF6;&#x5B9A;&#x65F6;&#x5668;&#x6CA1;&#x6709;&#x4F7F;&#x7528;&#xFF0C;&#x8C03;&#x5EA6;&#x5668;&#x4E0D;&#x9700;&#x8981;&#x53BB;&#x6267;&#x884C;&#x5B9A;&#x65F6;&#x5668;&#x56DE;&#x8C03;&#x51FD;&#x6570;
</li>
<li>&#x6240;&#x6709;&#x7684;&#x4EFB;&#x52A1;&#x90FD;&#x5904;&#x5728;&#x65E0;&#x9650;&#x671F;&#x7684;&#x6302;&#x8D77;&#x6216;&#x8005;&#x963B;&#x585E;&#x6001;&#xFF0C;&#x56E0;&#x6B64;&#x8C03;&#x5EA6;&#x5668;&#x4E0D;&#x9700;&#x8981;&#x53BB;&#x5C06;&#x4EFB;&#x52A1;&#x8F6C;&#x6362;&#x4E3A;&#x5C31;&#x7EEA;&#x6001;&#x3002;
</li></ol>
<p>&#x5728;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x8C03;&#x7528;&#x6216;&#x8005;&#x7ED3;&#x675F;&#x4E4B;&#x524D;&#xFF0C;&#x4E3A;&#x4E86;&#x9632;&#x6B62;&#x4E0E;RTOS&#x7684;&#x8C03;&#x5EA6;&#x5668;&#x4EA7;&#x751F;&#x6761;&#x4EF6;&#x7ADE;&#x4E89;&#xFF0C;&#x8C03;&#x5EA6;&#x5668;&#x5904;&#x5728;&#x6302;&#x8D77;&#x7684;&#x72B6;&#x6001;&#x4E0B;&#x3002;&#x8FD9;&#x53EF;&#x4EE5;&#x6709;&#x6548;&#x4FDD;&#x8BC1;&#x5E94;&#x7528;&#x4EFB;&#x52A1;&#x4E0D;&#x4F1A;&#x518D;&#x5904;&#x7406;&#x5668;&#x4ECE;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#x9000;&#x51FA;&#x548C;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x6267;&#x884C;&#x5B8C;&#x6210;&#x4E4B;&#x524D;&#x5C31;&#x6267;&#x884C;&#x3002;&#x8FDB;&#x4E00;&#x6B65;&#x7684;&#xFF0C;&#x6709;&#x5FC5;&#x8981;&#x5728;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5C0F;&#x7684;&#x4E34;&#x754C;&#x4EE3;&#x7801;&#x6BB5;&#xFF0C;&#x8FD9;&#x4E2A;&#x4E34;&#x754C;&#x4EE3;&#x7801;&#x6BB5;&#x4F4D;&#x4E8E;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x505C;&#x6B62;&#x548C;&#x5904;&#x7406;&#x5668;&#x8FDB;&#x5165;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#x4E4B;&#x524D;&#xFF0C;<code>eTaskConfirmSleepModeStatus<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x5E94;&#x8BE5;&#x5728;&#x8FD9;&#x4E2A;&#x4E34;&#x754C;&#x6BB5;&#x4E2D;&#x8C03;&#x7528;&#xFF0C;&#x53BB;&#x68C0;&#x67E5;&#x5F53;&#x524D;&#x7684;&#x4EFB;&#x52A1;&#x72B6;&#x6001;&#x3002;</p><p>&#x6240;&#x6709;&#x7684;GCC&#x3001;IAR&#x3001;Keil&#x3001;ARM Cotex-M3/4&#x5206;&#x652F;&#x63D0;&#x4F9B;&#x9ED8;&#x8BA4;&#x7684;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x5B9E;&#x73B0;&#x3002;&#x4E00;&#x4E9B;&#x4F7F;&#x7528;ARM Cotex M&#x7CFB;&#x5217;&#x5904;&#x7406;&#x5668;&#x7684;&#x91CD;&#x8981;&#x4FE1;&#x606F;&#x53EF;&#x4EE5;&#x53C2;&#x9605; <a href="Low%20Power%20Features%20For%20ARM%20Cortex-M%20MCUs%20page."></a>,<em>&#x8FD9;&#x4E9B;&#x548C;&#x5177;&#x4F53;&#x5904;&#x7406;&#x5668;&#x76F8;&#x5173;&#x7684;&#x5E94;&#x7528;&#x4FE1;&#x606F;&#x53EF;&#x80FD;&#x4E0D;&#x4F1A;&#x53BB;&#x7FFB;&#x8BD1;&#xFF0C;&#x9664;&#x975E;&#x5C06;&#x6765;&#x6211;&#x81EA;&#x5DF1;&#x4F7F;&#x7528;&#x5230;&#x8FD9;&#x4E9B;&#x5904;&#x7406;&#x5668;</em></p><p>&#x9ED8;&#x8BA4;&#x7684;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#x5B9E;&#x73B0;&#x4F1A;&#x5728;&#x5C06;&#x6765;&#x9010;&#x6B65;&#x52A0;&#x5165;&#x5230;&#x6240;&#x6709;&#x652F;&#x6301;&#x7684;&#x5206;&#x652F;&#x4E2D;&#xFF0C;&#x540C;&#x65F6;&#xFF0C;&#x4E0B;&#x9762;&#x63CF;&#x8FF0;&#x7684;&#x529F;&#x80FD;&#x53EF;&#x4EE5;&#x7528;&#x5728;&#x6240;&#x6709;&#x7684;&#x5206;&#x652F;&#xFF0C;&#x7528;&#x4EE5;&#x6781;&#x901F;&#x4F4E;&#x8282;&#x62CD;&#x529F;&#x80FD;&#xFF1A;</p><h2 id="&#x5B9E;&#x73B0;portsuppressticksandsleep">&#x5B9E;&#x73B0;portSUPPRESS_TICKS_AND_SLEEP()</h2><p>&#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528;&#x7684;&#x5904;&#x7406;&#x5668;&#x6CA1;&#x6709;&#x63D0;&#x4F9B;&#x9ED8;&#x8BA4;&#x7684;<code>portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span></code>&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5728;<code>FreeRTOSConfig.h</code>&#x4E2D;&#x81EA;&#x5DF1;&#x53BB;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x5B8F;&#x3002;&#x5F53;&#x7136;&#x5982;&#x679C;&#x9ED8;&#x8BA4;&#x5B8F;&#x8FBE;&#x4E0D;&#x5230;&#x4F60;&#x7684;&#x76EE;&#x7684;&#xFF0C;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x91CD;&#x5199;&#x8FD9;&#x4E2A;&#x9ED8;&#x8BA4;&#x5B8F;&#x3002;</p><p>&#x770B;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p><pre><code>/* &#x9996;&#x5148;&#x5B9A;&#x4E49;portSUPPRESS_TICKS_AND_SLEEP<span class="token punctuation">(</span><span class="token punctuation">)</span>&#x5B8F;&#xFF0C;&#x53C2;&#x6570;&#x662F;&#x5185;&#x6838;&#x4E0B;&#x6B21;&#x9700;&#x8981;&#x6267;&#x884C;&#x7684;&#x7B49;&#x5F85;&#x65F6;&#x95F4; */
<span class="token comment" spellcheck="true">#define portSUPPRESS_TICKS_AND_SLEEP( xIdleTime ) vApplicationSleep( xIdleTime )</span>

/* &#x5B9A;&#x4E49;&#x4E0E;&#x5904;&#x7406;&#x5668;&#x76F8;&#x5173;&#x7684;&#x7761;&#x7720;&#x51FD;&#x6570; */
void vApplicationSleep<span class="token punctuation">(</span> TickType_t xExpectedIdleTime <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
unsigned long ulLowPowerTimeBeforeSleep, ulLowPowerTimeAfterSleep<span class="token punctuation">;</span>
eSleepModeStatus eSleepStatus<span class="token punctuation">;</span>

    /* &#x8BB0;&#x5F55;&#x8FDB;&#x5165;&#x4F4E;&#x529F;&#x8017;&#x4E4B;&#x524D;&#x7684;&#x65F6;&#x95F4; */
    ulLowPowerTimeBeforeSleep <span class="token operator">=</span> ulGetExternalTime<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    /* &#x505C;&#x6B62;&#x4EA7;&#x751F;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x7684;&#x5B9A;&#x65F6;&#x5668; */
    prvStopTickInterruptTimer<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    /* &#x8FDB;&#x5165;&#x4E34;&#x754C;&#x4EE3;&#x7801;&#x6BB5;&#xFF0C;&#x524D;&#x63D0;&#x662F;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5524;&#x9192; */
    disable_interrupts<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    /* &#x518D;&#x6B21;&#x786E;&#x8BA4;&#x662F;&#x5426;&#x6EE1;&#x8DB3;&#x7761;&#x7720;&#x6761;&#x4EF6;. */
    eSleepStatus <span class="token operator">=</span> eTaskConfirmSleepModeStatus<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    if<span class="token punctuation">(</span> eSleepStatus <span class="token operator">==</span> eAbortSleep <span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        /* &#x6709;&#x4EFB;&#x52A1;&#x4ECE;&#x963B;&#x585E;&#x6001;&#x79FB;&#x51FA;&#x6216;&#x8005;&#x7B49;&#x5F85;&#x4E0A;&#x4E0B;&#x6587;&#x5207;&#x6362;&#xFF0C;&#x4E0D;&#x80FD;&#x8FDB;&#x5165;&#x7761;&#x7720;&#xFF0C;
        &#x91CD;&#x542F;&#x4EA7;&#x751F;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x7684;&#x5B9A;&#x65F6;&#x5668;&#x548C;&#x4F7F;&#x80FD;&#x4E2D;&#x65AD;. */
        prvStartTickInterruptTimer<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        enable_interrupts<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">{</span>
        if<span class="token punctuation">(</span> eSleepStatus <span class="token operator">==</span> eNoTasksWaitingTimeout <span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            /* &#x6CA1;&#x6709;&#x914D;&#x7F6E;&#x5C06;&#x5904;&#x7406;&#x5668;&#x4ECE;&#x4F4E;&#x529F;&#x8017;&#x6A21;&#x5F0F;&#x5524;&#x9192;&#x7684;&#x4E2D;&#x65AD;&#x7684;&#x5FC5;&#x8981;&#xFF0C;&#x76F4;&#x63A5;&#x8FDB;&#x5165;&#x7761;&#x7720; */
            prvSleep<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">else</span>
        <span class="token punctuation">{</span>
            /* &#x5728;&#x5185;&#x6838;&#x4E0B;&#x6B21;&#x9700;&#x8981;&#x6267;&#x884C;&#x7684;&#x65F6;&#x95F4;&#xFF0C;&#x914D;&#x7F6E;&#x5524;&#x9192;&#x6E90;&#x5C06;&#x5904;&#x7406;&#x5668;&#x5524;&#x9192;&#xFF0C;&#x4F8B;&#x5982;RTC&#x3002; */
            vSetWakeTimeInterrupt<span class="token punctuation">(</span> xExpectedIdleTime <span class="token punctuation">)</span><span class="token punctuation">;</span>

            /* &#x8FDB;&#x5165;&#x7761;&#x7720;&#x72B6;&#x6001;. */
            prvSleep<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            /* &#x7528;&#x6765;&#x8BA1;&#x7B97;&#x5904;&#x7406;&#x5668;&#x5904;&#x5728;&#x7761;&#x7720;&#x72B6;&#x6001;&#x7684;&#x65F6;&#x95F4;&#xFF0C;&#x540E;&#x9762;&#x4FEE;&#x6B63;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x7684;&#x8BA1;&#x6570;&#x503C;&#x4F1A;&#x7528;&#x5230; */
            ulLowPowerTimeAfterSleep <span class="token operator">=</span> ulGetExternalTime<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            /* &#x4FEE;&#x6B63;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x8BA1;&#x6570;&#x503C;&#xFF0C;&#x8FD9;&#x6837;&#x7684;&#x5904;&#x7406;&#x663E;&#x7136;&#x662F;&#x4E0D;&#x662F;&#x5F88;&#x7CBE;&#x786E;&#x7684;&#xFF0C;&#x5B98;&#x65B9;&#x4E5F;&#x5728;&#x8BD5;&#x56FE;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x66F4;&#x7CBE;&#x786E;&#x7684;&#x65F6;&#x95F4;&#x4FEE;&#x6B63;. */
            vTaskStepTick<span class="token punctuation">(</span> ulLowPowerTimeAfterSleep &#x2013; ulLowPowerTimeBeforeSleep <span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        /* &#x9000;&#x51FA;&#x4E34;&#x754C;&#x6BB5; */
        enable_interrupts<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        /* &#x91CD;&#x542F;&#x8282;&#x62CD;&#x4E2D;&#x65AD;&#x5B9A;&#x65F6;&#x5668;*/
        prvStartTickInterruptTimer<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>

                                
                                </section>
                            
                        </div>
                    </div>
                
            </div>

            
                
                <a href="跟踪特性.html" class="navigation navigation-prev " aria-label="Previous page: 跟踪特性">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="运行时间统计.html" class="navigation navigation-next " aria-label="Next page: 运行时间统计">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"低功耗支持","level":"1.4.4","depth":2,"next":{"title":"运行时间统计","level":"1.4.5","depth":2,"path":"进阶/高级/运行时间统计.md","ref":"进阶/高级/运行时间统计.md","articles":[]},"previous":{"title":"跟踪特性","level":"1.4.3","depth":2,"path":"进阶/高级/跟踪特性.md","ref":"进阶/高级/跟踪特性.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prismx","-highlight","-search","duoshuo","ga","theme-comscore"],"styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"ga":{"configuration":"auto","token":"UA-80700049-1"},"duoshuo":{"short_name":"tangguocheng","theme":"default"},"prismx":{"css":["prismjs/themes/prism-tomorrow.css"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-comscore":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"mobi":{"fontSize":12,"footerTemplate":null,"headerTemplate":null,"margin":{"bottom":36,"left":62,"right":62,"top":36},"pageNumbers":false,"paperSize":"a4"},"theme":"default","author":"tangguocheng","pdf":{"pageBreaksBefore":"/","headerTemplate":null,"paperSize":"a4","margin":{"right":62,"left":62,"top":36,"bottom":36},"fontSize":12,"fontFamily":"Arial","footerTemplate":null,"chapterMark":"pagebreak","pageNumbers":false},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"freeRTOS中文文档","language":"Chinese","links":{"sidebar":{"博客":"http://www.xn--4gqa63c686ta68iba.ren/"}},"gitbook":"*","description":"freeRTOS中文文档","extension":null},"file":{"path":"进阶/高级/低功耗支持.md","mtime":"2016-09-08T07:34:08.003Z","type":"markdown"},"gitbook":{"version":"3.2.0","time":"2016-09-18T09:07:11.640Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-duoshuo/duoshuo.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-ga/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

